package com.cn.client.util;

import com.cn.client.vo.orderAndVisitorVo.CountAmount;
import com.cn.client.vo.orderAndVisitorVo.GenerateOrder;
import com.cn.dto.CouponDTO;

import java.math.BigDecimal;

public  class Tool {

    public static BigDecimal CountAmount(CountAmount countAmount) {
        BigDecimal price = countAmount.getProductAmount();//票价
        BigDecimal adultQuantity = BigDecimal.valueOf(countAmount.getAdultQuantity());//成人数
        BigDecimal childrenQuantity = BigDecimal.valueOf(countAmount.getChildrenQuantity());//儿童数
        BigDecimal bigDecimal = new BigDecimal("0.5");
        return price.multiply(adultQuantity).add(price.multiply(childrenQuantity).multiply(bigDecimal));
    }

    public static String CreateOrder(GenerateOrder generateOrder){
        String userId= String.valueOf(generateOrder.getUserId());
        String productId=String.valueOf(generateOrder.getProductId());
        String currentTimeMillis = String.valueOf(System.currentTimeMillis());
        return userId+productId + currentTimeMillis;
    }

    public  static BigDecimal CouponAmount(BigDecimal amount, CouponDTO couponDTO){
        if (couponDTO.getType().equals("现金券")){
          return   amount.subtract(couponDTO.getCoupon_amount());
        }
        return amount.multiply(couponDTO.getCoupon_amount());
    }

}
